<template>
  <div class="aside">
    <el-menu :default-active="$store.state.path" class="el-menu-vertical-demo" theme="dark" router>
      
      <!-- add 2018.12.29 -->
      <!-- <el-submenu index="/teacherManage">
        <template slot="title">教师管理</template>
        <el-menu-item v-if="privilegeArray.includes('3')" index="/teacherManage/info" @click="gotoThis({name:'教职工基本信息',url:'/teacherManage/info'})">教职工基本信息</el-menu-item>
        <el-menu-item v-if="privilegeArray.includes('4')" index="/teacherManage/paper" @click="gotoThis({name:'学术论文统计',url:'/teacherManage/paper'})">学术论文统计</el-menu-item>
        <el-menu-item v-if="privilegeArray.includes('5')" index="/teacherManage/scientific" @click="gotoThis({name:'科技著作出版统计',url:'/teacherManage/scientific'})">科技著作出版统计</el-menu-item>
        <el-menu-item v-if="privilegeArray.includes('6')" index="/teacherManage/meetings" @click="gotoThis({name:'学术会议统计',url:'/teacherManage/meetings'})">学术会议统计</el-menu-item>
        <el-menu-item v-if="privilegeArray.includes('7')" index="/teacherManage/communicate" @click="gotoThis({name:'学术交流活动统计',url:'/teacherManage/communicate'})">学术交流活动统计</el-menu-item>
        <el-menu-item v-if="privilegeArray.includes('8')" index="/teacherManage/teaching" @click="gotoThis({name:'教学信息统计',url:'/teacherManage/teaching'})">教学信息统计</el-menu-item>
      </el-submenu> -->
    
      <el-menu-item v-for="(item, index) in $store.state.commonMenu" v-if="!item.children&&privilegeArray.includes(item.privilege)"  :key="index" :index="item.url" @click="gotoThis(item)">{{item.name}}</el-menu-item>
      <el-submenu v-else-if="item.children&&item.children.length>0&&privilegeArray.includes(item.privilege)" :index="item.url">
        <template slot="title">{{item.name}}</template>
        <el-menu-item v-for="(child, index) in item.children" v-if="privilegeArray.includes(child.privilege)"  :key="index" :index="child.url" @click="gotoThis(child)">{{child.name}}</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
  import http from '../../assets/js/http'
  export default {
    data(){
      return{
        isInstructor: false,
        isBanZhuRen: false,
        privilegeArray:[],
      }
    },
    
    methods:{
      gotoThis(item){
        this.$store.state.tablename=item.tablename
        this.$store.state.search.params=[]
        this.$store.state.theader.label=item.name
      },

      getPrivilege(){
        _g.apiPost("auth/find").then(res=>{
          this.privilegeArray=Array.isArray(res.data.content)?res.data.content:Object.values(res.data.content)
        })
      }
    },
    created(){
      this.getPrivilege()
      bus.$on("getList",()=>{
        this.getPrivilege()
      })
    },
    mixins: [http]
  }
</script>
<style scoped>
  .aside{
    flex: none;
    width: 220px;
    text-align: center;
    height: 100%;
    background-color:#3B4966;
  }
  .aside .el-menu{
    background-color:#3B4966;
    height: 100%;
    overflow: auto;
    overflow-x: hidden;
  }
  .aside .el-menu-item{
    height: 60px;
    line-height: 60px;
    font-size: 16px;
    color: #fff;
  }
  .aside .el-menu-item:hover,.is-active{
    background: #56678a url(../../../resource/imgs/icon-tri.png) right no-repeat;
  }

</style>
